<template>
	<page-body>
		<view class="page">
			<view
				class="flex flex-direction flex-wrap align-stretch justify-center benben-position-layout flex myInfo_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-stretch justify-between myInfo_fd0_0'>
					<view class='flex flex-wrap align-center myInfo_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">
						<image class='myInfo_fd0_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"139.png"'></image>
					</view>
					<view class='flex flex-wrap align-center'>
						<text class='myInfo_fd0_0_c1_c0'>我的资料</text>
					</view>
					<view class='flex align-center justify-end myInfo_fd0_0_c2'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---我的资料flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch">
				<view class='flex flex-direction align-stretch myInfo_fd1_0'>
					<view class='flex flex-wrap align-center myInfo_fd1_0_c0'>
						<text class='myInfo_fd1_0_c0_c0'>头像</text>
						<benben-image-upload :path.sync="dataDetails.avatar" :img-id.sync="dataDetails.avatar"
							:is-cropping="true" :is-show-clean="false"
							class="upload position-relative myInfo_fd1_0_c0_c1">

							<image class=" myInfo_fd1_0_c0_c1_image" mode="aspectFill"
								:src="dataDetails.avatar ? dataDetails.avatar : STATIC_URL+'140.png'"></image>
						</benben-image-upload>
					</view>
					<!-- <view class='flex flex-wrap align-center justify-between myInfo_fd1_0_c0'>
						<text class='myInfo_fd1_0_c0_c0'>ID</text>
						<text class='myInfo_fd1_0_c1_c1'>3657868</text>
					</view> -->
					<view class='flex flex-wrap align-center justify-between myInfo_fd1_0_c0'>
						<text class='myInfo_fd1_0_c0_c0'>昵称</text>
						<benben-input class='flex-sub myInfo_fd1_0_c2_c1' type="text" :placeholder="`请输入昵称`"
							confirm-type="done" :maxlength="7"
							placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx"
							v-model="dataDetails.nickname" />
					</view>
					<!-- <view class='flex flex-wrap align-center justify-between myInfo_fd1_0_c0'>
						<text class='myInfo_fd1_0_c0_c0'>学校</text>
						<text class='myInfo_fd1_0_c1_c1'>林晨曦</text>
					</view> -->
					<view class='flex flex-wrap align-center justify-between myInfo_fd1_0_c0'
						@tap.stop="pickerDiy1656985489961=true">
						<text class='myInfo_fd1_0_c0_c0'>性别</text>
						<benben-input class='flex-sub myInfo_fd1_0_c4_c1' type="text" :placeholder="`请选择性别`"
							confirm-type="done" :maxlength="-1" :disabled='true'
							placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx" v-model="sex" />
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub myInfo_fd1_0_c0'
						@tap.stop="pickerDiy1656986153485=true">
						<text class='myInfo_fd1_0_c0_c0'>生日</text>
						<benben-input class='flex-sub myInfo_fd1_0_c4_c1' type="text" :placeholder="`请选择生日`"
							confirm-type="done" :maxlength="-1" :disabled='true'
							placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx"
							v-model="dataDetails.birthday" />
					</view>
					<view class='flex flex-wrap align-center justify-between myInfo_fd1_0_c0' @tap.stop="pickerDiy1715242438727 = true">
						<text class='myInfo_fd1_0_c0_c0'>学校</text>
						<!-- <text class='myInfo_fd1_0_c1_c1'>西安财经大学(长安校区)</text> -->
						<benben-input class='flex-sub myInfo_fd1_0_c4_c1' type="text" :placeholder="`请选择学校`"
							confirm-type="done" :maxlength="-1" :disabled='true'
							placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx"
							v-model="schoolLable" />
					</view>
					<view class='flex flex-wrap align-center justify-between myInfo_fd1_0_c0'>
						<text class='myInfo_fd1_0_c0_c0'>学号</text>
						<!-- <text class='myInfo_fd1_0_c1_c1'>20210861545454</text> -->
						<benben-input class='flex-sub myInfo_fd1_0_c2_c1' type="text" :placeholder="`请输入学号`"
							confirm-type="done" :maxlength="-1"
							placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx"
							v-model="dataDetails.student_number" />
					</view>
					
				</view>
			</view>

			<!---我的资料flex布局结束-->
			<!--选择生日开始 -->
			<benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1656986153485"
				:value.sync='dataDetails.birthday' mode='date' :picker-height='88' :current='true' :mask-show='true'
				fields='day' :timeout='true' start-year='1950-01-01' end-year='现在'>
				<template #picker-header>
					<view class='flex flex-wrap align-center justify-between myInfo_picker2_0'>
						<text class='myInfo_picker2_0_c0' @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
						<text class='myInfo_picker2_0_c1'>选择日期</text>
						<text class='myInfo_picker2_0_c2'
							@tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确定</text>
					</view>
				</template>
			</benben-picker>
			<!--选择生日结束 -->
			<!--选择性别开始 -->
			<benben-picker ref="benbenWritePickerCodepicker3" :visible.sync="pickerDiy1656985489961" :label.sync='sex'
				:value.sync='dataDetails.gender' :options='sexType' mode='selector' :mask-show='true' :timeout='true'
				:picker-height='88' default-type='value' :default-props='{"label":"name","value":"value"}'>
				<template #picker-header>
					<view class='flex flex-wrap align-center justify-between myInfo_picker3_0'>
						<text class='myInfo_picker3_0_c0' @tap="$refs.benbenWritePickerCodepicker3.cancel()">取消</text>
						<text class='myInfo_picker3_0_c1'>选择性别</text>
						<text class='myInfo_picker3_0_c2'
							@tap="$refs.benbenWritePickerCodepicker3.pickerConfirm()">确定</text>
					</view>
				</template>
			</benben-picker>
			<!--选择性别结束 -->
			<benben-picker ref="benbenWritePickerCodepicker4" :visible.sync="pickerDiy1715242438727" :label.sync='schoolLable' :value.sync='schoolValue'
			:options='schoolType' mode='selector' :mask-show='true' :timeout='true'  default-type='aid' :picker-height='88' :default-props='{"label":"name","value":"aid"}' >
			    <template #picker-header>
			        <view class='flex flex-wrap align-center justify-between index_picker4_0'>
			            <text class='index_picker4_0_c0' @tap="$refs.benbenWritePickerCodepicker4.cancel()">取消</text>
			            <text class='index_picker4_0_c1'>选择学校</text>
			            <text class='index_picker4_0_c2' @tap="$refs.benbenWritePickerCodepicker4.pickerConfirm()">确定</text>
			        </view>
			    </template>
			</benben-picker>
			<view class="flex flex-wrap align-center justify-center benben-position-layout flex myInfo_flex_4" @tap.stop="editUserFunc">
				<text class='myInfo_fd4_0'>保存</text>

			</view>
			<view :style="{height: '110rpx'}"></view>


		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				schoolValue:'',
				schoolLable:'',
				schoolType:[],
				pickerDiy1715242438727:false,
				"pickerDiy1656985489961": false,
				"pickerDiy1656986153485": false,
				"sexType": [{
					"name": "保密",
					"value": "0",
					"image": ""
				}, {
					"name": "男",
					"value": "1",
					"image": ""
				}, {
					"name": "女",
					"value": "2",
					"image": ""
				}],
				"editUser": {},
				"dataDetails": {
					"invite_code": "",
					"address": "",
					"address_code": "",
					"hobby": "",
					"tags": "",
					"id": "",
					"userlevel_id": "",
					"mobile": "",
					"real_name": "",
					"avatar": "",
					"account": "",
					"email": "",
					"birthday": "",
					"gender": "",
					"create_time": "",
					"user_money": "",
					"freeze_money": "",
					"total_consumption_money": "",
					"score": "",
					"_mobile": "",
					"coupon": "",
					"collection_count": "",
					"browse_count": "",
					"total_money": "",
					"certified": "",
					"nickname": "",
					"is_pay_password": "",
					"follow_count": ""
				},
				"dataMessage": {
					"userinfo": {
						"id": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": ""
					}
				},
				"sex": "",
				"isCheck": false
			};
		},
		computed: {
			userInfo: {
				get() {
					return this.$store.state.userInfo
				},
				set() {
					this.$store.commit('updateUserInfo', value)
				},
			}
		},
		watch: {},
		onLoad() {
			this.getUserinfoFunc()
			this.diyPageListen()
			this.getso66f98f91a240Func()
		},
		onUnload() {
			this.diyOffPageListen()
		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//修改个人信息
			async editUserFunc() {
				// console.log(this.schoolValue)
				// return
				if (this.isCheck === true) {
					return
				} else {
					if (!this.dataDetails.nickname) {
						this.$message.info('请输入昵称！');
						return false;
					}
					// if (!validate(this.dataDetails.nickname, 'length', '1,7')) {
					// 	this.$message.info('最多7个字符');
					// 	return false;
					// }
					this.isCheck = true;
					//请求方法
					//数据验证

					let datadataMessage = await this.$api.post(global.apiUrls.post5cb54af125f1c, {
						avatar: this.dataDetails.avatar,
						nickname: this.dataDetails.nickname,
						gender: this.dataDetails.gender,
						birthday: this.dataDetails.birthday,
						school_id:this.schoolValue,
						student_number:this.dataDetails.student_number,
					});

					if (datadataMessage.data.code != 1) {
						this.$message.info(datadataMessage.data.msg);
						return
					}
					let infodataMessage = datadataMessage.data;
					this.dataMessage = infodataMessage.data

					setTimeout(() => {
						this.isCheck = false;
					}, 500)
					this.$message.info('保存成功');
					setTimeout(() => {
						this.$urouter.navigateBack(1);
					}, 800)
				}
			},
			//获取个人信息
			async getUserinfoFunc(data) {
				let datadataDetails = await this.$api.get(global.apiUrls.post5c78c4772da97, {

				});

				if (datadataDetails.data.code != 1) {
					this.$message.info(datadataDetails.data.msg);
					return
				}
				let infodataDetails = datadataDetails.data;
				// if (data) {
				// 	this.dataDetails.nickname = infodataDetails.data.nickname
				// } else {
					this.dataDetails = infodataDetails.data
					if (this.dataDetails.gender == '1') {
						this.sex = '男';
					} else if (this.dataDetails.gender == '2') {
						this.sex = '女';
					} else {
						this.sex = '保密';
					}
					this.schoolValue = this.dataDetails.school_id  
					this.schoolLable = this.dataDetails.school_name  
				// }
			},
			//页面监听
			diyPageListen() {
				uni.$on('chengeName', (data) => {
					this.getUserinfoFunc(data)
				});
			},
			//注销页面监听
			diyOffPageListen() {
				uni.$off('chengeName');
			},
			async getso66f98f91a240Func() {
			    //请求方法
			    //数据验证
			
			    let dataschoolType = await this.$api.get(global.apiUrls.post666f98f91a240, {
			
			    });
			
			    if (dataschoolType.data.code != 1) {
			        this.$message.info(dataschoolType.data.msg);
			        return
			    }
			    let infoschoolType = dataschoolType.data;
			    this.schoolType = infoschoolType.data
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(248, 248, 248, 1);
		background-size: 100% auto;
	}

	.myInfo_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.myInfo_fd0_0_c2 {
		padding: 0rpx 0rpx 0rpx 0rpx;
		width: 100rpx;
	}

	.myInfo_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		line-height: 50rpx;
	}

	.myInfo_fd0_0_c0_c0 {
		width: 18rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.myInfo_fd0_0_c0 {
		width: 100rpx;
	}

	.myInfo_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.myInfo_fd1_0_c5 {
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.myInfo_fd1_0_c4_c1 {
		font-size: 32rpx;
		font-weight: 400;
		line-height: 32rpx;
		text-align: right;
		color: var(--benbenFontColor1);
	}

	.myInfo_fd1_0_c2_c1 {
		text-align: right;
		font-size: 32rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		margin: 0rpx 0rpx 0rpx 32rpx;
	}

	.myInfo_fd1_0_c1_c1 {
		color: #666666;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 45rpx;
	}

	.myInfo_fd1_0_c0_c1_image {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
	}

	.myInfo_fd1_0_c0_c1 {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.myInfo_fd1_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
	}

	.myInfo_fd1_0_c0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.myInfo_fd1_0 {
		background: var(--benbenbgColor1);
		padding: 0rpx 32rpx 0rpx 32rpx;
		background-size: 100% auto !important;
	}

	.myInfo_picker2_0_c2 {
		color: #FF8E21;
		line-height: 40rpx;
		font-size: 32rpx;
		font-weight: 500;
	}

	.myInfo_picker2_0_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.myInfo_picker2_0_c0 {
		line-height: 40rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: var(--benbenFontColor1);
	}

	.myInfo_picker2_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
		border-radius: 25rpx 25rpx 0rpx 0rpx;
		background-size: 100% auto !important;
	}

	.myInfo_picker3_0_c2 {
		color:#FF8E21;
		line-height: 40rpx;
		font-size: 32rpx;
		font-weight: 500;
	}

	.myInfo_picker3_0_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.myInfo_picker3_0_c0 {
		line-height: 40rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #BFBFBF;
	}

	.myInfo_picker3_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
		border-radius: 25rpx 25rpx 0rpx 0rpx;
		background-size: 100% auto !important;
	}

	.myInfo_flex_4 {
		background: var(--benbenbgColor1);
		width: 750rpx;
		height: 110rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		background-size: 100% auto;
	}

	.myInfo_fd4_0 {
		color: #FF8E21;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
	}
	.index_picker4_0_c2 {
	    color: #FF8E21;
	    font-size: 32rpx;
	    // font-weight: 700;
	    line-height: 40rpx;
	    text-align: left;
	    font-style: normal;
	}
	
	.index_picker4_0_c1 {
	    color: #333333;
	    font-size: 36rpx;
	    font-weight: 700;
	    line-height: 50rpx;
	    text-align: left;
	    font-style: normal;
	}
	
	.index_picker4_0_c0 {
	    color: #999999;
	    font-size: 28rpx;
	    font-weight: 400;
	    line-height: 40rpx;
	    text-align: left;
	    font-style: normal;
	}
	.index_picker4_0 {
	    border-bottom: 1px solid #eee;
	    background: #fff;
	    padding: 0rpx 32rpx 0rpx 32rpx;
	    border-radius: 24rpx 24rpx 0rpx 0rpx;
	    background-size: 100% auto !important;
	    height: 110rpx;
	}
</style>
